<template>
	<om-formsub-outer :index="index" :checkedit="checkedit" :deleteBtn="false">
		<om-autoform ref="autoform" :initConfigData="autoformdata" :initValue="initValue"></om-autoform>
	</om-formsub-outer>
</template>

<script>
	import {buildSubFormData, subOnLoad, changeEditor,configSelectData,hasValue} from '@/static/js/formUtil.js';
	import { ignoreHtml,errorModal,ptFloat,minusF,getDateStr} from '@/static/js/common.js';
	export default {
		provide() {
			return {
				formPage: this
			};
		},
		data() {
			return buildSubFormData({
				origHandleWayList:[],
				userId:''
			})
		},
		methods:{
			onSelectHandleWay(item){
				let _that = this
				if(item.code == "37697"){
					_that.getTipAfterHandleWay(item.code)
				}else if(item.code == "35516"){
					_that.getTipAfterHandleWay(item.code)
					_that.$refs.autoform.clear("title_orig","origEffectDate")
					_that.$refs.autoform.changeEditor("title_orig","origEffectDate","type","labelbox")
				}else{
					_that.$refs.autoform.clear("title_orig","origEffectDate")
					_that.$refs.autoform.changeEditor("title_orig","origEffectDate","type","labelbox")
				}
				if(_that.checkedit){
					if(_that.formdata.origHandleWayCode != item.code){
						_that.$refs.autoform.formdata.isChanged = true
					}
				}
			},
			getTipAfterHandleWay(code){
				let _that = this
				_that.om.request(
					"tempInstAdjust/getTipAfterHandleWay",
					{
						posId: _that.formdata.origPosId,
						userId:_that.userId
					}
				).then(res=>{
					if(res.value){
						errorModal(_that,'提示信息',ignoreHtml(res.value),()=>{
							_that.$refs.autoform.clear("title_orig","origHandleWayCode")
						})
					}else{
						if(code == "37697"){
							_that.$refs.autoform.changeEditor("title_orig","origEffectDate","type","datebox")
							_that.$refs.autoform.changeEditor("title_orig","origEffectDate","prompt","请选择")
						}
					}
				})
			},
			initLoad(){
				let _that = this
				
			}
		},
		onShow() {
			
		},
		onLoad(e) {
			let _that = this
			subOnLoad(_that, e, function() {
			if(e.configDataCacheKey){
				uni.getStorage({
					key: e.configDataCacheKey,
					success: function(res) {
						if(res.data && Object.prototype.toString.call(res.data)==='[object Array]'){
							_that.autoformdata = res.data
							Object.assign(_that.initValue, _that.formdata)
							_that.autoformdata[0].order = _that.order
							if(e.userId){
								_that.userId = e.userId
							}
								changeEditor("title_orig","origHandleWayCode","data",configSelectData(JSON.parse(e.origHandleWayList),"code","dicname"),_that.autoformdata)
							}
							if(_that.formdata.origHandleWayCode == '37697'){
								changeEditor("title_orig","origEffectDate","type","datebox",_that.autoformdata)
								changeEditor("title_orig","origEffectDate","prompt","请选择",_that.autoformdata)
							}
						}
					})
				}
				_that.$nextTick(function(){
					_that.$refs.autoform.initSelectIndex("title_orig","origHandleWayCode")
				})			
			})
		}
	}
</script>

<style>
</style>                                                                                                                                                                                                                                                                                                                                                                                                                                                         
